﻿using Gj;
using UnityEngine;

public class SafeSize : NodeSize
{
    public RectTransform rectTransform;
    public float offset = 80;
    public NodeSize[] safeList;

    protected override void OnRefresh(float rw, float rh, float w, float h, float s)
    {
        if (Game.GetDevicePlatform() != "Mobile") return;
        if (SystemInput.screenOrientation == ScreenOrientation.LandscapeLeft)
        {
            rectTransform.offsetMin = new Vector2(offset, 0);
            rectTransform.offsetMax = new Vector2(0, 0);
        }

        if (SystemInput.screenOrientation == ScreenOrientation.LandscapeRight)
        {
            rectTransform.offsetMin = new Vector2(0, 0);
            rectTransform.offsetMax = new Vector2(offset * -1, 0);
        }
        for (var i = 0; i < safeList.Length; i++) safeList[i].Refresh(rw - offset, rh, w, h, s);
    }
}